package com.android.qjpmc.widget.dialogfragment;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;

import com.android.qjpmc.R;
import com.android.qjpmc.databinding.DialogFragmentInputStationCodeBinding;
import com.android.qjpmc.databinding.DialogFragmentMessageBinding;
import com.android.qjpmc.listener.MessageDlialogListener;
import com.android.qjpmc.widget.utils.ToastUtils;
import com.facebook.stetho.common.StringUtil;

public class InputStationDialogFragment extends BaseDialogFragment<DialogFragmentInputStationCodeBinding> {

    private InputStationDialogListener listener;

    @Override
    public int getLayoutRes() {
        return R.layout.dialog_fragment_input_station_code;
    }

    @Override
    public void initView(Context context, View rootView, AttributeSet attrs) {
        mBinding.setView(this);
    }

    @Override
    public void initData(Context context) {
    }

    @Override
    public void initEvent(Context context) {

    }

    @Override
    public void dismiss() {
        super.dismiss();
    }

    public void onNegative() {
        dismiss();
    }

    public void onPositive() {
        String code = mBinding.etCode.getText().toString();
        if (TextUtils.isEmpty(code)) {
            ToastUtils.showShort("请输入code");
            return;
        }
        dismiss();
        listener.onInputCode(code);
    }

    @Override
    public int getGravity() {
        return Gravity.CENTER;
    }


    public void setInputStationDialogListener(InputStationDialogListener listener) {
        this.listener = listener;
    }

    public interface InputStationDialogListener {
        void onInputCode(String code);
    }
}

